﻿using UnityEngine;
using System.Collections;

public class enemy2_Rocket : MonoBehaviour {

	//玩家
	GameObject m_player;
	//速度
	float m_speed =4;
	//子弹威力
	public int m_Power = 1;
	//生存时间
	float m_timer = 4;
	Transform m_Transform;
	void Start () {
	
		m_Transform = this.transform;
		m_player = GameObject.FindGameObjectWithTag("Player");
	}

	void Update () {
		m_Transform.Translate(new Vector3(0,m_speed*Time.deltaTime,0));
		m_timer-=Time.deltaTime;
		if(m_timer<=0)
		{
			Destroy(this.gameObject);
		}
	}

	void OnTriggerEnter2D(Collider2D other)
	{
		if(other.tag.CompareTo("Player") == 0)
		{
			Destroy(this.gameObject);
		}else if(other.tag.CompareTo("Bounds") == 0)
		{
			Destroy(this.gameObject,0.1F);
		}
	}

}
